package cn.tedu.mall.seckill.timer.config;

import cn.tedu.mall.seckill.timer.job.SeckillInitialJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail initJobDetail(){
        return  JobBuilder.newJob(SeckillInitialJob.class).withIdentity("initJobDetail")
                .storeDurably().build();

    }
    @Bean
    public Trigger initTrigger(){
        CronScheduleBuilder cron =CronScheduleBuilder.cronSchedule("0 0/1 * * * ?");
        return TriggerBuilder.newTrigger().forJob(initJobDetail()).withIdentity("initTrigger")
                .withSchedule(cron).build();

    }



}
